<%@page contentType="text/html; charset=utf-8"%>
<%@ include file="../inc/TagLibs.jsp"%>
<c:set var="pageTitle" value="选择项目价格" />
<%@ include file="../inc/Title.jsp"%>
<head>
<link href="/css/Query.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" type="text/css" href="/css/BillList.css" />
<script src="/js/QueryList.js"></script>
<script src="/js/popup_ext.js"></script>
<script language="javascript">
    function doNew(){
    	var priceType="${priceType}";
		var url="";
		if(priceType=='EST'){
			url="/base/EstPriceNew.ihtm?est_type=${estType}&price_type="+priceType+"&est_id=${est.id}";
		}else{
			url="/base/EstPriceNew.ihtm?est_type=${estType}&price_type="+priceType;
		}
		ShowIframe("项目价格",url,1024,400,"refreshWin()");
	}
	function refreshWin(){
		if(popRetVal!=null){
			window.location=window.location;
		}
	}
	function doSelect(index){
		var ob_arr = document.getElementsByName("query_checkbox");
		var arr=new Array();
		if ( ob_arr.length>=index ){
			var obj=ob_arr[index-1];
			arr[0]=new Array(obj.getAttribute("mt_id"),obj.getAttribute("mt_nam"),obj.getAttribute("p_id"),obj.getAttribute("p_nam"),obj.getAttribute("mk_req"),obj.getAttribute("unit"),obj.getAttribute("price"),obj.getAttribute("wc_id"),obj.getAttribute("wc_name"),obj.getAttribute("len"),obj.getAttribute("wid"),obj.getAttribute("spe"),obj.getAttribute("mt_type"));
			parent.popRetVal=arr;
		}
		parent.ClosePop();
	}
	function doSearch(){
		var mtId=document.getElementById("mt_id").value;
		var proName=document.getElementById("pro_name").value.trim();
		if(proName=="录入材质名称查询"){
			proName="";
		}else{
			proName=encodeURIComponent(proName);
		}
		window.location="/base/EstPriceListForSelect.ihtm?type=${type}&unit_rang=${unitRang}&est_id=${est.id}&est_type=${estType}&price_type=${priceType}&mt_id="+mtId+"&pro_name="+proName;
	}
	function doGo(pageIndex){
		var proName=encodeURIComponent("${proName}");
		window.location="/base/EstPriceListForSelect.ihtm?type=${type}&unit_rang=${unitRang}&est_id=${est.id}&est_type=${estType}&price_type=${priceType}&mt_id=${mtId}&pro_name="+proName+"&current_page="+pageIndex;
	}
	function doJump(pageIndex){
		if(window.event.keyCode==13){
			doGo(pageIndex);
		}
	}
	function DoubleClick(it){
		var ob_arr = document.getElementsByName("query_checkbox");
		var arr=new Array();
		if(ob_arr.length>=it.getAttribute("index")){
			var obj=ob_arr[it.getAttribute("index")-1];
			arr[0]=new Array(obj.getAttribute("mt_id"),obj.getAttribute("mt_nam"),obj.getAttribute("p_id"),obj.getAttribute("p_nam"),obj.getAttribute("mk_req"),obj.getAttribute("unit"),obj.getAttribute("price"),obj.getAttribute("wc_id"),obj.getAttribute("wc_name"),obj.getAttribute("len"),obj.getAttribute("wid"),obj.getAttribute("spe"),obj.getAttribute("mt_type"));
			parent.popRetVal=arr;
		}
		parent.ClosePop();
	}
	function doMutiSelect(){
		var ob_arr = document.getElementsByName("query_checkbox");
		var arr=new Array();
		for (i=0;i<ob_arr.length;i++){
			if ((ob_arr[i].checked == true)){
				arr.push(new Array(ob_arr[i].getAttribute("mt_id"),ob_arr[i].getAttribute("mt_nam"),ob_arr[i].getAttribute("p_id"),ob_arr[i].getAttribute("p_nam"),ob_arr[i].getAttribute("mk_req"),ob_arr[i].getAttribute("unit"),ob_arr[i].getAttribute("price"),ob_arr[i].getAttribute("wc_id"),ob_arr[i].getAttribute("wc_name"),ob_arr[i].getAttribute("len"),ob_arr[i].getAttribute("wid"),ob_arr[i].getAttribute("spe"),ob_arr[i].getAttribute("mt_type")));
			}
		}
		if(arr.length>0){
			parent.popRetVal=arr;
			parent.ClosePop();
		}else{
			ShowAlert('提示框','请选择项目价格！',200,100);
			return;
		}
	}
	function checkProName(){
		if(window.event.keyCode==13){
			doSearch();
		}
	}
	function proNameFocus(){
		if(document.getElementById("pro_name").value=="录入材质名称查询"){
			document.getElementById("pro_name").value="";
		}
	}
	function proNameBlur(){
		if(document.getElementById("pro_name").value==""){
			document.getElementById("pro_name").value="录入材质名称查询";
		}
	}
	function doInit(){
		resizePopwin();
		document.getElementById("pro_name").focus();
	}
</script>
</head>
<body oncontextmenu="return false" class="sheet" onload="doInit();">
<c:if test="${estType=='CLIENT'}">
	<c:if test="${currentUser.user.userType==1 || fn:indexOf(currentUser.privs,';CLIE_PRIC;')!=-1 && fn:indexOf(currentUser.privs,';NO_PRIC_EDIT;')==-1}"><c:set var="canOper" value="Y" /></c:if>
</c:if>
<c:if test="${estType=='PROVIDER'}">
	<c:if test="${currentUser.user.userType==1 || fn:indexOf(currentUser.privs,';PROV_PRIC;')!=-1 && fn:indexOf(currentUser.privs,';NO_PRIC_EDIT;')==-1}"><c:set var="canOper" value="Y" /></c:if>
</c:if>
<c:if test="${estType=='COOPERATOR'}">
	<c:if test="${currentUser.user.userType==1 || fn:indexOf(currentUser.privs,';COOP_PRIC;')!=-1 && fn:indexOf(currentUser.privs,';NO_PRIC_EDIT;')==-1}"><c:set var="canOper" value="Y" /></c:if>
</c:if>
<body oncontextmenu="return false">
<div class="Wrap"><!-- 页面主框架 -->
    
	<div id="ListContainer" class="Container"><!-- 主体容器 -->
	    
	    <!-- 标题栏 -->
	    <div class="Heading BillIcon">
	        <div class="HeadingContent">
	            <h1><c:if test="${priceType=='EST'}">${est.estName}</c:if><c:if test="${priceType=='STA'}">标准价格</c:if></h1>
	            <span class="Note">选择项目价格</span>
	        </div>
	    </div>
	
		<!-- 主内容 -->
		<div class="Content">
	        <!-- 筛选控件栏 -->
	        <div class="FilterBar ClearFix">
	            <div class="SearchIcon"></div>
	            <span class="fr">
	            	<select name="mt_id" id="mt_id" style="width:200px">
						<option value="0">请选择项目类型</option>
						<commonTag:createSelectTree list="${mtList}" emptyOption="0" defaultValue="${mtId}" />
				  	</select>
		            <input type="text" class="TextBox" id="pro_name" name="pro_name" onKeyUp="checkProName();" onfocus="proNameFocus();" onblur="proNameBlur();" style="width:100px" <c:if test="${proName==null || proName==''}">value="录入材质名称查询"</c:if><c:if test="${proName!=null && proName!=''}">value="${proName}"</c:if> title="以材质名称或者材质的拼音字头进行模糊查询">
		            <input type="button" class="buttom search-but" value=" 查 询" onClick="doSearch();">
		            <c:if test="${canOper=='Y'}">
					  	<input type="button" value=" 新 增" onClick="doNew();" class="buttom search-add" >
					</c:if>
		            <input type="button" class="buttom search-select" value=" 选 择" onClick="doMutiSelect();">
	            </span>
			</div>
			
			<!-- 提示信息显示栏 -->
	        <div class="MsgBar">
	            <%@include file="../inc/AlertMsg.jsp"%>
	        </div>

	     	<div class="table-list">
		        <table width="100%">
		          	<tr>
					  	<th width="14"><input type="checkbox" onClick="javascript:checkall(this);"></th>
						<th width="10%">项目类型</th>
						<th width="14%">材质</th>
						<th width="14%">规格</th>
						<th width="8%">单位</th>
						<th width="10%">单价</th>
						<th width="18%">制作要求</th>
						<th width="16%">备注</th>
						<th width="10%">操作</th>
				 	</tr>
				 	<c:forEach var="item" items="${qr.list}" varStatus="i">
				 	<c:if test="${(i.index mod 2)==0}"><c:set var="trClass" value="query_list_data_tr1" /></c:if>
					<c:if test="${(i.index mod 2)!=0}"><c:set var="trClass" value="query_list_data_tr2" /></c:if>
					<tr class="${trClass}" index="${i.index+1}" onmouseout='javascript:mouseout(this)' onmouseover='javascript:mouseover(this)'>
						<td style='cursor:pointer;' ondblclick='javascript:DoubleClick(this.parentElement)' onClick='javascript:ClickCheck(this.parentElement,true)'><input type="checkbox" onClick="javascript:ClickCheck(this,true);" name='query_checkbox' mt_id="${item[0]}" mt_nam="${item[1]}" p_nam="<c:out value="${item[2]}" />" unit="<c:out value="${item[3]}" />" price="${item[4]}" mk_req="<c:out value="${item[5]}" />" wc_id="${item[7]}" wc_name="<c:out value="${item[8]}" />" len="<c:out value="${item[9]}" />" wid="<c:out value="${item[10]}" />" spe="<c:out value="${item[11]}" />" mt_type="${item[13]}" p_id="${item[14]}"></td>
						<td style='cursor:pointer;' ondblclick='javascript:DoubleClick(this.parentElement)' onClick='javascript:ClickCheck(this.parentElement,true)'>${item[1]}</td>
						<td style='cursor:pointer;' ondblclick='javascript:DoubleClick(this.parentElement)' onClick='javascript:ClickCheck(this.parentElement,true)'>${item[2]}</td>
						<td style='cursor:pointer;' ondblclick='javascript:DoubleClick(this.parentElement)' onClick='javascript:ClickCheck(this.parentElement,true)'>${item[11]}</td>
						<td style='cursor:pointer;' ondblclick='javascript:DoubleClick(this.parentElement)' onClick='javascript:ClickCheck(this.parentElement,true)'>${item[3]}</td>
						<td style='cursor:pointer;' ondblclick='javascript:DoubleClick(this.parentElement)' onClick='javascript:ClickCheck(this.parentElement,true)'>${item[4]}</td>
						<td style='cursor:pointer;' ondblclick='javascript:DoubleClick(this.parentElement)' onClick='javascript:ClickCheck(this.parentElement,true)'>${item[5]}</td>
						<td style='cursor:pointer;' ondblclick='javascript:DoubleClick(this.parentElement)' onClick='javascript:ClickCheck(this.parentElement,true)'>${item[6]}</td>
						<td>
							<c:if test="${item[12]!=null && item[12]!=''}"><a href="${item[12]}" target="_blank">图片</a></c:if>
							<a href="javascript:doSelect('${i.index+1}');">选择</a>
						</td>
				    </tr>
					</c:forEach>
				</table>
			</div>
			
			<c:set var="showPagesSelectButton" value="Y" />
	  		<c:set var="pagesSelectButtonFun" value="doMutiSelect()" />
	  		<div class="BottomToolBar ClearFix">
				<%@include file="../inc/Pages.jsp"%>
			</div>
			
		</div>
	</div>
</div>
</body>
</html>
<script type="text/javascript">
	function ChangeWindowSize( container, maxWidth ){
	    setTimeout( function(){
	        var w1 = document.documentElement.clientWidth-40;
	        if( w1>maxWidth ) w1 = maxWidth;
	        else if( w1<870 ) w1 = 860;
	        container.style.width = w1+'px';
	    }, 300 );
	}
	var IsAdvSearch = false;
	(function(){
		doInit();
	    var ListContainer = document.getElementById('ListContainer');
	    ChangeWindowSize( ListContainer, 2020 );    // 超过 1280 的最大 1260 ，不全部铺满
	})();
</script>